package club.xyes.zkh.ecommerce.commons.entity;

import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.Column;
import javax.persistence.Table;

/**
 * Create by 郭文梁 2019/4/17 0017 09:22
 * ShopImage
 * 商铺图片
 *
 * @author 郭文梁
 * @data 2019/4/17 0017
 */
@EqualsAndHashCode(callSuper = true)
@Data
@Table(name = "t_shop_image")
public class ShopImage extends BaseEntity {
    /**
     * 从商铺对象创建商铺图片
     *
     * @param shop 商铺对象
     * @return 商铺图片
     */
    public static ShopImage fromShop(Shop shop) {
        ShopImage image = new ShopImage();
        image.setShopId(shop.getId());
        image.setShop(shop);
        return image;
    }

    /**
     * 商铺ID
     */
    @Column(name = "shop_id", length = 10, nullable = false)
    private Integer shopId;
    /**
     * 关联的Shop对象
     */
    private Shop shop;
    /**
     * 图片路径
     */
    @Column(name = "image_url", nullable = false)
    private String imageUrl;

    /**
     * 是否为绝对路径
     * 以http:// 或 https://开头的为绝对路径
     */
    @Column(name = "absolutely", nullable = false)
    private Boolean absolutely;
}
